package top.superflow.service.config

import org.springframework.web.bind.annotation.{PathVariable, RequestMapping, ResponseBody, RestController}
import top.superflow.flow.config.FlowConfig
import top.superflow.flow.config.process.ProcessConfig
import top.superflow.flow.load.GlobalFlowConfiguration
import top.superflow.flow.mapper.MapperConfig
import top.superflow.flow.runtime.cache.FlowRunTimeCache
import top.superflow.flow.runtime.flow.ExtFlow
import top.superflow.flow.runtime.mapper.RuntimeMapper
import top.superflow.service.FlowManagerAware


@RestController
@RequestMapping(Array("/config"))
class FlowConfigService extends FlowManagerAware{


  @RequestMapping(Array("/flow/all"))
  @ResponseBody
  def getAllFlow:  List[FlowConfig] = {
    val flowConfigs = GlobalFlowConfiguration.getInstance.getFlows

    val flowList = toList[FlowConfig](flowConfigs)

    flowList.toList
  }

  @RequestMapping(Array("/mapper/all"))
  @ResponseBody
  def getAllMapper: List[ MapperConfig] = {
    val mapperConfigs = GlobalFlowConfiguration.getInstance.getMappers

    toList[MapperConfig](mapperConfigs).toList
  }

  @RequestMapping(Array("/process/all"))
  @ResponseBody
  def getAllProcesses: List[ ProcessConfig] = {
    val processConfigs = GlobalFlowConfiguration.getInstance.getProcesses

    toList[ProcessConfig](processConfigs).toList
  }


}
